# 1,0,2017/11/02-14:19:55
# 2,10,2017/11/02-14:20:05
from datetime import datetime
from datetime import timedelta
import random


def gen_log(log, cycle, start_time, cycle_time_min, cycle_time_max, cycle_time_bad, cycle_time_bad_freq):
    ts = start_time
    with open(log, 'w') as f:
        for n in range(cycle):
            if random.random() < cycle_time_bad_freq:
                cycle_time = cycle_time_bad
            else:
                cycle_time = random.randint(cycle_time_min, cycle_time_max)
            a_cyc = [n, cycle_time, ts.strftime('%Y/%m/%d-%H:%M:%S')]
            a_cyc = [str(i) for i in a_cyc]
            f.write(','.join(a_cyc) + '\n')
            ts += timedelta(seconds=cycle_time)
    
    # print file(log).read()

gen_log('test-01A-080027df0e00-os_centos.cfg-0013-1000.csv', 13, datetime.now(), 3*60, 5*60, 20*60, 0.005)
gen_log('test-01B-080027004db6-os_centos.cfg-0100-1000.csv', 100, datetime.now(), 3*60, 5*60, 20*60, 0.005)
gen_log('test-02A-080027a75cd9-os_centos.cfg-1000-1000.csv', 1000, datetime.now(), 3*60, 5*60, 20*60, 0.005)

